<template>
  <div class="symbo-operation">
    <div class="symbo-main">
      <div class="symbo-left" v-disabled-body-scroll="rotate">
        <div
          :class="[
            'symbo-left-item',
            classActiveIndex == index ? 'active' : '',
          ]"
          v-for="(item, index) in symbolArray"
          :key="index"
          @click="classItemClick(item, index)"
        >
          <span>{{ item.label }}</span>
        </div>
      </div>
      <div class="symbo-right" ref="symboRight" v-disabled-body-scroll="rotate">
        <div
          class="symbo-right-item"
          v-for="(item, index) in activeList"
          :key="index"
          @click.stop.prevent="append(item)"
        >
          <span> {{ item.txt }}</span>
        </div>
      </div>
    </div>
    <div class="symbo-bottom">
      <div class="symbo-bottom-right">
        <div class="symbo-bottom-item" @click.stop.prevent="deleteFn">
          <span class="icon iconfont icon-delete span-text"></span>
        </div>
        <div class="symbo-bottom-item" @click.stop.prevent="symbolBackFn">
          返回
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import symbolArray from "./maps";
import EventKeys from "@enu/eventKeys.js";
import { directive as disabledBodyScroll } from "disable-body-scroll";
export default {
  inject: ["symbolBackFn", "rotate"],
  data() {
    return {
      symbolArray: [...symbolArray],
      classActiveIndex: 0,
    };
  },
  directives: {
    "disabled-body-scroll": disabledBodyScroll,
  },
  computed: {
    activeList() {
      return this.symbolArray[this.classActiveIndex].list;
    },
  },
  methods: {
    classItemClick(item, index) {
      this.classActiveIndex = index;
      this.$nextTick(() => {
        this.$refs["symboRight"].scrollTo(0, 0);
      });
    },
    deleteFn() {
      this.$root.$emit(EventKeys["vue-keyboard-cn-append-delete"]);
    },
    append(item) {
      this.$root.$emit(EventKeys["vue-keyboard-cn-append-item"], item);
    },
  },
};
</script>
<style lang="scss" scoped>
.symbo-operation {
  // position: fixed;
  // height: 40vh;
  // left: 0;
  // bottom: 0;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;

  width: 100%;
  display: flex;
  flex-direction: column;
  background: #dedede;
  .symbo-main {
    height: 100%;
    display: flex;
    overflow: hidden;
    .symbo-left {
      width: 60px;
      height: 100%;
      overflow: auto;
      background: #dedede;
      font-size: 16px;
      .symbo-left-item {
        height: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        &::before {
          content: "";
          display: block;
          position: absolute;
          left: 0;
          bottom: 0;
          width: 100%;
          height: 1px;
          transform: scaleY(0.5);
          z-index: 1;
          background: #bfbfbf;
        }
        &.active {
          background: #bfbfbf;
        }
      }
    }
    .symbo-right {
      flex: 1;
      height: 100%;
      overflow: auto;
      background: #dedede;
      display: flex;
      flex-wrap: wrap;
      .symbo-right-item {
        height: 40px;
        line-height: 40px;
        width: 25%;
        display: flex;
        justify-content: center;
        align-content: center;
        position: relative;
        font-size: 16px;

        &::after {
          content: "";
          display: block;
          position: absolute;
          right: 0;
          top: 0;
          height: 100%;
          width: 1px;
          transform: scaleX(0.5);
          z-index: 1;
          background: #dedede;
        }
        &::before {
          content: "";
          display: block;
          position: absolute;
          left: 0;
          bottom: 0;
          width: 100%;
          height: 1px;
          transform: scaleY(0.5);
          z-index: 1;
          background: #dedede;
        }
        background: #fff;
      }
    }
  }
  .symbo-bottom {
    height: 40px;
    background: #bfbfbf;
    display: flex;
    justify-content: flex-end;
    align-content: center;
    .symbo-bottom-right {
      display: flex;
      align-items: center;
    }
    .symbo-bottom-item {
      width: 40px;
      font-size: 16px;
      text-align: center;
      .iconfont {
        font-size: 30px !important;
      }

      & + .symbo-bottom-item {
        margin-left: 10px;
      }
    }
  }
}
</style>